#include <Math.h>
#include <Square.h>

Square::Square (float side)
{
    m_side = (checkValid(side)) ? floor(side) : 0;
}

float Square::getArea() const
{
    return isValid() ? round(m_side * m_side) : 0;
}

float Square::getPerimeter() const
{
    return isValid() ? 4 * (m_side) : 0;
}

float Square::getSide() const
{
    return m_side;
}

bool Square::setSide(float value)
{
    if (!(checkValid(value)))
    {
        return false;
    }
    m_side = floor(value);
    return true;
}

bool  Square::isSideValid() const
{
    return checkValid(m_side);
}

bool  Square::isValid() const
{
    return isSideValid();
}


